<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.16"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>DesignPattern: C:/96_project/DesignPattern/10_Composite/DESIGNPATTERN_Directory.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="DesignPattern.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">DesignPattern
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.16 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_dbfba622dfdcb1864982b79adc9807da.html">10_Composite</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">DESIGNPATTERN_Directory.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___directory_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160; </div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="stdafx_8h.html">stdafx.h</a>&quot;</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160; </div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#ifndef CXX_DESIGNPATTERN_DIRECTORY_H</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_d_e_s_i_g_n_p_a_t_t_e_r_n___directory_8h.html">DESIGNPATTERN_Directory.h</a>&quot;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160; </div>
<div class="line"><a name="l00023"></a><span class="lineno"><a class="line" href="class_directory.html#ae41c9b6e859402114d9c21c4aa79785d">   23</a></span>&#160;<a class="code" href="class_directory.html#ae69ee52f5cacf4480b13364efa9c4682">Directory::Directory</a>(<span class="keyword">const</span> <span class="keywordtype">string</span>&amp; strName, <span class="keywordtype">int</span> iSize) :</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;    <a class="code" href="class_entry.html">Entry</a>(ENTRY_DIRECTORY, strName, iSize)</div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;{</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;    <a class="code" href="_my_self_def_8h.html#a0be11ce2e33906806ac4e521781809c0">DEBUG_PRINTF</a>(<span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;}</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160; </div>
<div class="line"><a name="l00035"></a><span class="lineno"><a class="line" href="class_directory.html#affbde8714685c61601421097d621341d">   35</a></span>&#160;<a class="code" href="class_directory.html#affbde8714685c61601421097d621341d">Directory::~Directory</a>()</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;{</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;    <a class="code" href="_my_self_def_8h.html#a0be11ce2e33906806ac4e521781809c0">DEBUG_PRINTF</a>(<span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;    list&lt;Entry*&gt;::iterator iter;</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;    <span class="keywordflow">for</span> (iter = <a class="code" href="class_directory.html#a0773cc315db8a754b2f88cdcf8dc680b">m_listEntry</a>.begin(); iter != <a class="code" href="class_directory.html#a0773cc315db8a754b2f88cdcf8dc680b">m_listEntry</a>.end(); iter++) {</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;        <span class="keywordflow">if</span> (NULL != (*iter)) {</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;            <span class="keyword">delete</span> (*iter);</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;            (*iter) = NULL;</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;        }</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    }</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;}</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160; </div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;<a class="code" href="_my_self_def_8h.html#a7927e087749615dae3114cc27b91c86d">VOID</a> </div>
<div class="line"><a name="l00054"></a><span class="lineno"><a class="line" href="class_directory.html#aa204b314dcd600af1cfd704bdaf08efb">   54</a></span>&#160;<a class="code" href="class_directory.html#aa204b314dcd600af1cfd704bdaf08efb">Directory::PrintList</a>()</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;{</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    <a class="code" href="_my_self_def_8h.html#a0be11ce2e33906806ac4e521781809c0">DEBUG_PRINTF</a>(<span class="stringliteral">&quot;name[%s], size[%d]&quot;</span>, <a class="code" href="class_entry.html#a9348775cf8b55054abf38518205b53a6">GetName</a>().c_str(), <a class="code" href="class_directory.html#aa83745f69713f3e57da36b37324aa361">GetSize</a>());</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;    <a class="code" href="class_entry.html#a0b7ce573c95c6960bec2b37ff6350279">Entry::PrintList</a>();</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160; </div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;    list&lt;Entry*&gt;::iterator iter;</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;    <span class="keywordflow">for</span> (iter = <a class="code" href="class_directory.html#a0773cc315db8a754b2f88cdcf8dc680b">m_listEntry</a>.begin(); iter != <a class="code" href="class_directory.html#a0773cc315db8a754b2f88cdcf8dc680b">m_listEntry</a>.end(); iter++) {</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;        (*iter)-&gt;PrintList();</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;    }</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;}</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160; </div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;<span class="keywordtype">int</span> </div>
<div class="line"><a name="l00072"></a><span class="lineno"><a class="line" href="class_directory.html#aa83745f69713f3e57da36b37324aa361">   72</a></span>&#160;<a class="code" href="class_directory.html#aa83745f69713f3e57da36b37324aa361">Directory::GetSize</a>()</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;{</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;    <a class="code" href="_my_self_def_8h.html#a0be11ce2e33906806ac4e521781809c0">DEBUG_PRINTF</a>(<span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;    <a class="code" href="class_entry.html#a9ff0e1f0770d5a3496891e549284e0c0">Entry::GetSize</a>();</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;    <span class="keywordtype">int</span> iSize = 0;</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;    list&lt;Entry*&gt;::iterator iter;</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;    <span class="keywordflow">for</span> (iter = <a class="code" href="class_directory.html#a0773cc315db8a754b2f88cdcf8dc680b">m_listEntry</a>.begin(); iter != <a class="code" href="class_directory.html#a0773cc315db8a754b2f88cdcf8dc680b">m_listEntry</a>.end(); iter++) {</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;        iSize += (*iter)-&gt;GetSize();</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    }</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    <span class="keywordflow">return</span> iSize;</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;}</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160; </div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;<span class="keywordtype">bool</span></div>
<div class="line"><a name="l00091"></a><span class="lineno"><a class="line" href="class_directory.html#a770eb2c0880e35f1d1a5e6cd15a4a5e9">   91</a></span>&#160;<a class="code" href="class_directory.html#a770eb2c0880e35f1d1a5e6cd15a4a5e9">Directory::Add</a>(<a class="code" href="class_entry.html">Entry</a>* pEntry)</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;{</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    <a class="code" href="_my_self_def_8h.html#a0be11ce2e33906806ac4e521781809c0">DEBUG_PRINTF</a>(<span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;    <a class="code" href="class_directory.html#a0773cc315db8a754b2f88cdcf8dc680b">m_listEntry</a>.push_back(pEntry);</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;}</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160; </div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;<span class="keywordtype">bool</span></div>
<div class="line"><a name="l00105"></a><span class="lineno"><a class="line" href="class_directory.html#a6a4a87769304b311ca28afeeced07705">  105</a></span>&#160;<a class="code" href="class_directory.html#a6a4a87769304b311ca28afeeced07705">Directory::Remove</a>(<a class="code" href="class_entry.html">Entry</a>* pEntry)</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;{</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;    <a class="code" href="_my_self_def_8h.html#a0be11ce2e33906806ac4e521781809c0">DEBUG_PRINTF</a>(<span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;    <a class="code" href="class_directory.html#a0773cc315db8a754b2f88cdcf8dc680b">m_listEntry</a>.remove(pEntry);</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;}</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160; </div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;list&lt;Entry*&gt;</div>
<div class="line"><a name="l00119"></a><span class="lineno"><a class="line" href="class_directory.html#a8de7e14fb73bc621cca52693049657f7">  119</a></span>&#160;<a class="code" href="class_directory.html#a8de7e14fb73bc621cca52693049657f7">Directory::GetChild</a>()</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;{</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;    <a class="code" href="_my_self_def_8h.html#a0be11ce2e33906806ac4e521781809c0">DEBUG_PRINTF</a>(<span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_directory.html#a0773cc315db8a754b2f88cdcf8dc680b">m_listEntry</a>;</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;}</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160; </div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;<span class="comment">/* EOF */</span></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclass_entry_html_a0b7ce573c95c6960bec2b37ff6350279"><div class="ttname"><a href="class_entry.html#a0b7ce573c95c6960bec2b37ff6350279">Entry::PrintList</a></div><div class="ttdeci">virtual VOID PrintList()</div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___entry_8cpp_source.html#l00056">DESIGNPATTERN_Entry.cpp:56</a></div></div>
<div class="ttc" id="aclass_directory_html_a8de7e14fb73bc621cca52693049657f7"><div class="ttname"><a href="class_directory.html#a8de7e14fb73bc621cca52693049657f7">Directory::GetChild</a></div><div class="ttdeci">virtual list&lt; Entry * &gt; GetChild()</div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___directory_8cpp_source.html#l00119">DESIGNPATTERN_Directory.cpp:119</a></div></div>
<div class="ttc" id="aclass_directory_html_a0773cc315db8a754b2f88cdcf8dc680b"><div class="ttname"><a href="class_directory.html#a0773cc315db8a754b2f88cdcf8dc680b">Directory::m_listEntry</a></div><div class="ttdeci">list&lt; Entry * &gt; m_listEntry</div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___directory_8h_source.html#l00110">DESIGNPATTERN_Directory.h:110</a></div></div>
<div class="ttc" id="aclass_directory_html_ae69ee52f5cacf4480b13364efa9c4682"><div class="ttname"><a href="class_directory.html#ae69ee52f5cacf4480b13364efa9c4682">Directory::Directory</a></div><div class="ttdeci">Directory()</div></div>
<div class="ttc" id="aclass_directory_html_affbde8714685c61601421097d621341d"><div class="ttname"><a href="class_directory.html#affbde8714685c61601421097d621341d">Directory::~Directory</a></div><div class="ttdeci">virtual ~Directory()</div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___directory_8cpp_source.html#l00035">DESIGNPATTERN_Directory.cpp:35</a></div></div>
<div class="ttc" id="aclass_entry_html_a9348775cf8b55054abf38518205b53a6"><div class="ttname"><a href="class_entry.html#a9348775cf8b55054abf38518205b53a6">Entry::GetName</a></div><div class="ttdeci">string GetName()</div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___entry_8cpp_source.html#l00082">DESIGNPATTERN_Entry.cpp:82</a></div></div>
<div class="ttc" id="a_my_self_def_8h_html_a7927e087749615dae3114cc27b91c86d"><div class="ttname"><a href="_my_self_def_8h.html#a7927e087749615dae3114cc27b91c86d">VOID</a></div><div class="ttdeci">void VOID</div><div class="ttdef"><b>Definition:</b> <a href="_my_self_def_8h_source.html#l00011">MySelfDef.h:11</a></div></div>
<div class="ttc" id="aclass_directory_html_a770eb2c0880e35f1d1a5e6cd15a4a5e9"><div class="ttname"><a href="class_directory.html#a770eb2c0880e35f1d1a5e6cd15a4a5e9">Directory::Add</a></div><div class="ttdeci">virtual bool Add(Entry *pEntry)</div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___directory_8cpp_source.html#l00091">DESIGNPATTERN_Directory.cpp:91</a></div></div>
<div class="ttc" id="aclass_directory_html_aa83745f69713f3e57da36b37324aa361"><div class="ttname"><a href="class_directory.html#aa83745f69713f3e57da36b37324aa361">Directory::GetSize</a></div><div class="ttdeci">virtual int GetSize()</div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___directory_8cpp_source.html#l00072">DESIGNPATTERN_Directory.cpp:72</a></div></div>
<div class="ttc" id="astdafx_8h_html"><div class="ttname"><a href="stdafx_8h.html">stdafx.h</a></div></div>
<div class="ttc" id="a_d_e_s_i_g_n_p_a_t_t_e_r_n___directory_8h_html"><div class="ttname"><a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___directory_8h.html">DESIGNPATTERN_Directory.h</a></div><div class="ttdoc">1.When the algorithm to create complex object should be independent of the part of the object,...</div></div>
<div class="ttc" id="aclass_directory_html_aa204b314dcd600af1cfd704bdaf08efb"><div class="ttname"><a href="class_directory.html#aa204b314dcd600af1cfd704bdaf08efb">Directory::PrintList</a></div><div class="ttdeci">virtual VOID PrintList()</div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___directory_8cpp_source.html#l00054">DESIGNPATTERN_Directory.cpp:54</a></div></div>
<div class="ttc" id="aclass_entry_html_a9ff0e1f0770d5a3496891e549284e0c0"><div class="ttname"><a href="class_entry.html#a9ff0e1f0770d5a3496891e549284e0c0">Entry::GetSize</a></div><div class="ttdeci">virtual int GetSize()</div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___entry_8cpp_source.html#l00095">DESIGNPATTERN_Entry.cpp:95</a></div></div>
<div class="ttc" id="aclass_entry_html"><div class="ttname"><a href="class_entry.html">Entry</a></div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___entry_8h_source.html#l00015">DESIGNPATTERN_Entry.h:15</a></div></div>
<div class="ttc" id="a_my_self_def_8h_html_a0be11ce2e33906806ac4e521781809c0"><div class="ttname"><a href="_my_self_def_8h.html#a0be11ce2e33906806ac4e521781809c0">DEBUG_PRINTF</a></div><div class="ttdeci">#define DEBUG_PRINTF(fmt, args...)</div><div class="ttdef"><b>Definition:</b> <a href="_my_self_def_8h_source.html#l00025">MySelfDef.h:25</a></div></div>
<div class="ttc" id="aclass_directory_html_a6a4a87769304b311ca28afeeced07705"><div class="ttname"><a href="class_directory.html#a6a4a87769304b311ca28afeeced07705">Directory::Remove</a></div><div class="ttdeci">virtual bool Remove(Entry *pEntry)</div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___directory_8cpp_source.html#l00105">DESIGNPATTERN_Directory.cpp:105</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.16
</small></address>
</body>
</html>
